<!DOCTYPE html>
<html lang="en">
<head>
    <!--[if lt IE 7]>
    <div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
                                                                               href="http://browsehappy.com">立即升级</a>
    </div>
    <![endif]-->
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <base href="<?php echo base_url(); ?>"/>
    <title>详细统计</title>
    <meta name="description"
          content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"/>
    <meta name="keywords" content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年"/>
    <meta name="copyright" content="上海易推信息科技有限公司"/>
    <link rel="shortcut icon" href="favicon.ico"/>
    <link rel="stylesheet" href="public/js/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="public/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/cost-center.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/popup.css"/>
    <link rel="stylesheet" href="public/css/bootstrap.min.css">
    <link rel="stylesheet" href="public/css/dcalendar.picker.css">
    <link rel="stylesheet" href="public/css/cqs.style.css">
    <!--[if lte IE 9]>
    <script type="text/javascript" src="public/js/html5shiv-printshiv-3.js"></script>
    <![endif]-->


    <style type="text/css">
        * {
            -webkit-box-sizing: unset;
            -moz-box-sizing: unset;
            box-sizing: unset;
        }

        dt, dd {
            line-height: unset;
        }

        .month {
            word-break: keep-all;
        }

        caption {
            display: none;
        }

        .button-default {
            display: none;
        }

        .arrow-box {
            cursor: pointer;
        }

        ul, ol {
            margin-bottom: 0px;
        }

    </style>
</head>
<body style="background-color: #f4f4f4;">
<?php $this->load->view('common/header.php'); ?>
<div class="cqs-main">
    <div class="cqs-main_top cqs-mgt30">数据报表：
        <?php if ($_SESSION['customer_info']['identity'] != 3): ?>
            <a class="cqs-clc40000" href="<?php echo base_url(); ?>information/information_purchase_user">采购用户统计＞</a>
        <?php else: ?>
            <a class="cqs-clc40000" href="<?php echo base_url(); ?>information/detail">采购用户统计＞</a>
        <?php endif; ?>
        <?php echo $customer['username']; ?>
    </div>
    <div class="cqs-main_con">
        <div class="cqs-main_left">
            <div class="cqs-title">年采购量
                <div class="date-box cqs-year">
                    <select class="form-control" style="background:#ffffff;width:86px;">
                        <?php if (date('Y') >= '2022'): ?>
                            <option <?php echo $y == '2022' ? "selected" : ""; ?>>2022年</option>
                        <?php endif; ?>
                        <?php if (date('Y') >= '2021'): ?>
                            <option <?php echo $y == '2021' ? "selected" : ""; ?>>2021年</option>
                        <?php endif; ?>
                        <?php if (date('Y') >= '2020'): ?>
                            <option <?php echo $y == '2020' ? "selected" : ""; ?>>2020年</option>
                        <?php endif; ?>
                        <?php if (date('Y') >= '2019'): ?>
                            <option <?php echo $y == '2019' ? "selected" : ""; ?>>2019年</option>
                        <?php endif; ?>
                        <option <?php echo $y == '2018' ? "selected" : ""; ?>>2018年</option>
                    </select>
                </div>

            </div>

            <div style="margin-left: 80px;" id="myChart" class="myChart"></div>

            <div class="i-char-hint">
                <span></span>平均实际采购
                <span class="cqs-bgd9f0ff"></span>（平均）每月预算
                <span class="cqs-bgc40000"></span>实际采购
            </div>
        </div>
        <div class="cqs-main_right">
            <div class="cqs-list_head">
                <div class="cqs-list_hd"><img class="head" src="<?php echo base_url(); ?>public/img/icon_zhanghao.png"
                                              alt=""></div>
                <div class="cqs-list_bd">
                    <?php if (isset($_SESSION['customer_info']['identity'])): ?>
                        <?php if ($_SESSION['customer_info']['identity'] != 3): ?>
                            <a class="more" target="_blank"
                               href="<?php echo base_url('cost_center/manager_user_edit'); ?>?id=<?php echo $customer['id']; ?>">查看资料＞</a>
                        <?php endif; ?>
                    <?php endif; ?>
                    <p>账号：<?php echo $customer['username']; ?></p>
                    <p>联系人：<?php echo $customer['name']; ?></p>
                    <p class="cqs-mgb30">联系方式：<?php echo $customer['tel']; ?></p>
                </div>
            </div>

            <div class="cqs-list_head">
                <div class="cqs-list_hd"><img class="head" src="<?php echo base_url(); ?>public/img/icon_yusuan.png"
                                              alt=""></div>
                <div class="cqs-list_bd">
                    <?php if (isset($_SESSION['customer_info']['identity'])): ?>
                        <?php if ($_SESSION['customer_info']['identity'] != 3): ?>
                            <a class="more" target="_blank"
                               href="<?php echo base_url('cost_center/manager_user_edit'); ?>?id=<?php echo $customer['id']; ?>#set-budget">修改预算＞</a>
                        <?php endif; ?>
                    <?php endif; ?>
                    <p>
                        预算（月）：￥<?php echo ($budget['budget'] && ($budget['budget'] != '0.00')) ? $budget['budget'] : "无限制"; ?></p>
                    <p>已使用：￥<?php echo $budget['used'] ? $budget['used'] : '0.00'; ?></p>
                    <p class="
                       cqs-mgb30">
                        <?php if ($budget['budget'] && $budget['budget'] > 0): ?>
                            剩余预算：￥<?php echo sprintf("%01.2f", $budget['budget'] - $budget['used']); ?>
                        <?php endif; ?>
                    </p>
                </div>
            </div>

            <div class="cqs-list_head">
                <div class="cqs-list_hd"><img class="head" src="<?php echo base_url(); ?>public/img/icon_caigou.png"
                                              alt=""></div>
                <div class="cqs-list_bd">
                    <p>平均每月采购：￥<?php echo sprintf("%01.2f", $year_money / date('n')); ?></p>
                    <p>今年累计采购：￥<?php echo $year_money; ?></p>
                    <p class="cqs-mgb30">累计采购次数：<?php echo $year_num; ?>次</p>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $this->load->view('common/bottom.php'); ?>
<script src="public/js/jquery.min.js"></script>
<script src="public/js/bootstrap-table.min.js"></script>
<script src="public/js/dcalendar.picker.js"></script>
<script src="public/js/ichart.1.2.min.js"></script>
<script>


    $(function () {
        var data = [
            {
                name: '北京',
                //value: [200, 2000, 1500, 2500, 2600, 3000, 3200, 2900, 2200, 1200, 1000, 5500],
                value: <?php echo $months_sale;?>,
                color: '#c40000',
                line_width: 2
            }
        ];
        var chart = new iChart.LineBasic2D({
            render: 'myChart',
            data: data,
            // title : '北京2012年平均温度情况',
            width: 630,
            height: 350,
            // offsetx: 80,
            // offsety: 50,
            coordinate: {height: '90%', width: '75%', background_color: '#ffffff', striped: false},
            sub_option: {
                hollow_inside: true,//设置一个点的亮色在外环的效果
                point_size: 10,
                smooth: true,
                label: false
            },
            tip: {
                enable: true,
                shadow: false,
                listeners: {
                    //tip:提示框对象、name:数据名称、value:数据值、text:当前文本、i:数据点的索引
                    parseText: function (tip, name, value, text, i) {
                        return "<span style='background-color#2b2d2e;font-size:20px;'>¥" + value + "</span>";
                    }
                }
            },
            align: 'center',
            border: 0,
            label: {
                color: '2b2d2e'
            },
            labels: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
        });
        /**
         *自定义组件,画平均线。
         */
        /*      //Custom plugin, show success and failure.
         chart.plugin(new iChart.Custom({
         drawFn:function(){
         //Position
         var coo = chart.getCoordinate(),
         x = coo.get('originx'),
         y = coo.get('originy'),
         w = coo.width,
         h = coo.height;
         //Render the text
         chart.target.textAlign('start')
         .textBaseline('bottom')
         .textFont('600 11px Times New Roman')
         .fillText('Success',x-50,y+h/4+5,false,'#3e576f')
         .textBaseline('top')
         .fillText('Failure',x-50,y+3*h/4-5,false,'#3e576f');
         console.log(x, y, w, h);
         }
         }));*/
        //Success line 平均实际采购
        var maxNum = 6000;
        var actualNum = 4500;
        var budgetNum = 1500;
        chart.plugin(new iChart.Custom({
            drawFn: function () {
                var avg = chart.total / 5,
                    coo = chart.getCoordinate(),
                    x = coo.get('originx'),
                    W = coo.width,
                    S = coo.getScale('left'),
                    H = coo.height,
                    h = (avg - S.start) * H / S.distance,
                    //y = chart.y + (H * (maxNum - actualNum)) / maxNum;
                    y = chart.y + (H * (H - H * (<?php echo $actual_money; ?>/S.end))) /
                H;
                chart.target.line(x, y, x + W, y, 2, '#f9de85')
                    .textAlign('start')
                    .textBaseline('middle')
                    .textFont('600 12px Verdana')
                    .fillText('平均实际采购\n<?php echo sprintf('%01.2f', $actual_money); ?>', x + W + 5, y, false, '#f9b81a');
            }
        }));

        //Failure line
        chart.plugin(new iChart.Custom({
            drawFn: function () {
                var avg = chart.total / 5,
                    coo = chart.getCoordinate(),
                    x = coo.get('originx'),
                    W = coo.width,
                    S = coo.getScale('left'),
                    H = coo.height,
                    h = (avg - S.start) * H / S.distance;
                //y = chart.y + (H * (maxNum - budgetNum)) / maxNum;
                if (<?php echo $budget_month; ?> >
                S.end
            )
                {
                    var bm = S.end;
                }
            else
                {
                    var bm = <?php echo $budget_month; ?>;
                }
                var y = chart.y + (H * (H - H * (bm / S.end))) /
                    H;
                console.log(x + W + 5);
                chart.target.line(x, y, x + W, y, 2, '#d9f0ff')
                    .textAlign('start')
                    .textBaseline('middle')
                    .textFont('200 12px Verdana')
                    .fillText('平均每月预算\n<?php echo sprintf('%01.2f', $budget_month); ?>', x + W + 5, y, false, '#208aff');
            }
        }));
        chart.draw();
    });

</script>
</body>
</html>